package top.leoseven.adminproject.view;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import top.leoseven.adminproject.R;

/**
 * Created by admin2 on 2018/4/11.
 */

public class ListFragment extends Fragment {
    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    private RecyclerView.LayoutManager lm;
    public void init(RecyclerView.Adapter adapter, RecyclerView.LayoutManager lm){
        this.adapter=adapter;
        this.lm=lm;
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_list, null, false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        recyclerView= (RecyclerView) view.findViewById(R.id.recycle);
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    }
    public void notifyDataSetChage(){
        adapter.notifyDataSetChanged();
    }

}
